import java.io.*;

public class CharStreamDemo {
    public static void writer(String dir,String name){
        File file = new File(dir,name);
        if(!file.exists()){
            try {
                file.createNewFile();
                FileWriter fw = new FileWriter(file);
                BufferedWriter bw = new BufferedWriter(fw);
                fw.write("书山有路勤为径，学海无涯苦作舟");
                fw.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
    public static void reader(String dir,String name){
        File file = new File (dir,name);
        if(file.exists()){
            try {
                FileReader fileReader = new FileReader(file);
                BufferedReader br = new BufferedReader(fileReader);
                String concent;
                while(true){

                    concent = br.readLine();
                    if(concent == null){
                        break;
                    }
                    System.out.println(concent);

                }
                br.close();
                fileReader.close();
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
